source icq.tcl

proc Event {event args} {
	if {[llength [info commands ICQ::$event]]} {
		if {[lindex $args 0]=="debug dump"} {
			#puts DEBUG_DUMP
		} else {
			puts "\nEXISTS $event\t\t$args"
		}
		eval icq::$event $args
		
	} else {
		puts "No handler for ICQ event $event"
	}
}
set icq [icq::icq 407306099 kellin -port 1024 -reconnect no \
		-event Event -capabilities {ICQ RELAY}]


namespace eval ICQ {
global icq
	proc Log {cmd level str} {
	if {$level=="debug"} {
		puts level_debug
	}
	if {$cmd=="debug"} {
		puts
	}
	#puts "LOG $args"
	}
	
	proc MyStatus {args} {
	puts "MyStatus $args"
	}
	
	proc Status {args} {
	puts "Status $args"
	}
	
	proc MyIP {args} {
	puts "MyIP $args"
	}
	
	proc IP {args} {
	puts "IP $args"
	}
	
	proc Client {args} {
	puts "Client $args"
	}
	
	proc Capabilities {args} {
	puts "Capabilities $args"
	}
	
	proc LanDetails {args} {
	puts "LanDetails $args"
	}
	
	proc SignonDate {args} {
	puts "SignonDate $args"
	}
	
	proc Roster:items {args} {
	puts "ROSTER==========================\n $args\n==========================="
	}
	
	
	
	proc Incoming {name uin time code enc msg rest {formatter FormatMessage}} {
		puts "\n\n====+=+=+=INCOMING name $name | type $type | uin $uin | time $time | messaage $message\n\n====+=+=+="
		foreach {type message} [$formatter $code $msg $rest $enc] break
			if {$type=="error"} {
				log $name {error message} "ERROR: $message"
			} elseif {$type=="autorequest"} {
				log $name {debug message} "$type message request via server"
				return $message
			} elseif {$type=="service"} {
				log $name {debug message} "$type message request via server, skipping"
			} else {
				log $name {debug message} "Message of subtype $code ($type)"
				log $name {debug message} "Data: $message"
				if {$type=="text"} { 
					set message [glue $name $message $uin]
				}
			}
		return ""
	}
}
$icq status online
vwait fin
